package com.cloudbroker.bcs.common.util;

import org.apache.commons.codec.language.bm.Lang;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;

public class DecimalFormatUtil {
    
    // number format
    
    public static String formatDecimalFix2(double amount) {
        return new DecimalFormat("0.00").format(amount);
    }
    
    public static String formatDecimalFix3(double amount) {
        return new DecimalFormat("0.000").format(amount);
    }
    
    public static String formatPercentageMax0(double ratio) {
        return new DecimalFormat("0%").format(ratio);
    }
    
    public static String formatPercentageMax2(double ratio) {
        return new DecimalFormat("0.##%").format(ratio);
    }
    
    public static String formatPercentageFix2(double ratio) {
        return new DecimalFormat("0.00%").format(ratio);
    }
    
    public static String formatPercentageFix3(double ratio) {
        return new DecimalFormat("0.000%").format(ratio);
    }
    
    public static String formatPermillageMax1(double ratio) {
        return new DecimalFormat("0.#‰").format(ratio);
    }
    
    public static String formatPermillageMax2(double ratio) {
        return new DecimalFormat("0.##‰").format(ratio);
    }
    
    public static String formatPermillageMax6(double ratio) {
        return new DecimalFormat("0.######‰").format(ratio);
    }

    public static String format(Number number, String pattern) {
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        return new DecimalFormat(pattern, symbols).format(number);
    }


}
